/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

// JAVA SCRIPT 4 PUSH SCREEN

    /*
     * Set selected style on click the source list
     */
    function changeStyleLeft(obj) {
        $j("#sourceDiv").children().removeClass("objSelect");
        $j(obj).addClass("objSelect");
    }

    /*
     * Set selected style on click the destination list
     */
    function changeStyleRight(obj) {
        $j("#destinationDiv").children().removeClass("objSelect");
        $j(obj).addClass("objSelect");
    }

    /*
     * Move the selected on source to the destination with other type on double click
     */
    function moveRight(obj) {
        // the "align" atrribute on source item contains ID item

        var idWork = $j(obj).attr("lang");
        // add item in dest list with 3 columns
        var str = "<div class='destinationItem' ondblclick='moveLeft(this)' onclick='changeStyleRight(this)'>"
        str +=      "<div class='desNameItem' style='border-right:0px;' lang='" + $j(obj).attr("lang") + "'>" + $j(obj).text() + "</div>";
        str +=    "</div>";
        $j("#destinationDiv").append(str);
        $j(obj).remove();
    }
    /*
     *
     * Move the selected on dest to the source with other type on double click
     */
    function moveLeft(obj) {
        var id = 0;
        var cost = 0;
        var day = 0;
        var name = "";

        $j(obj).find("div").each(function() {
            if($j(this).hasClass("desNameItem")) {
                id = $j(this).attr("lang");
                name = $j(this).text();
            }
        });
        $j("#sourceDiv").append("<div class='sourceItem' ondblclick='moveRight(this)' onclick='changeStyleLeft(this)' lang='" + id + "'" +">" + name + "</div>");
        $j(obj).remove();
    }

    /*
     * Move the selected on source to the destination with other type by button click
     */
    function moveBtnRight() {
        $j("#sourceDiv").find("div").each(function() {
            if($j(this).hasClass("objSelect")) {
                moveRight(this);
            }
        });
    }

    /*
     * Move the selected on dest to the source with other type by button click
     */
    function moveBtnLeft() {
        $j("#destinationDiv").find("div").each(function() {
            if($j(this).hasClass("objSelect")) {
                moveLeft(this);
            }
        });
    }

    /*
     * Move all from source to the dest with other type by button click
     */
    function moveAllRight() {
        $j("#sourceDiv").find("div").each(function() {
            if(!$j(this).hasClass("sourceItemHeader")) {
                moveRight(this);
            }
        });
    }

    /*
     * Move all from dest to the source with other type by button click
     */
    function moveAllLeft() {
        $j("#destinationDiv").find("div").each(function() {
            if($j(this).hasClass("destinationItem")) {
                moveLeft(this);
            }
        });
    }

// JAVA SCRIPT 4 PUSH SCREEN
